// 日志

let moment = require('moment');
let fs = require('fs');
let {EOL} = require('os');



// 常规日志
function writeLog(req,res,next){
  // 书写内容: 时间-请求ip-请求方式-请求地址-换行
  let time = moment(new Date()).format('YYYY-MM-DD hh:mm:ss')+ ' ';
  let ip = req.ip+' ';
  let method = req.method+' ';
  let url = req.url+' ';
  // 拼接写入
  let str = time+ip+method+url+EOL;
  fs.appendFileSync('./log/opt.log',str);
  next();
}


module.exports = {
  writeLog
}